package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"good_srv/good"
	"good_srv/internal/svc"
	"good_srv/models"
)

type MerchantContentLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMerchantContentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerchantContentLogic {
	return &MerchantContentLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商家评论添加
func (l *MerchantContentLogic) MerchantContent(in *good.MerchantContentRequest) (*good.MerchantContentResponse, error) {
	// todo: add your logic here and delete this line
	var err error
	contents := models.MerchantContent{
		MerchantId: in.MerchantId,
		OrderId:    in.OrderId,
		Content:    in.Content,
		Score:      in.Score,
		Image:      in.Image,
	}
	if err = contents.MAdd(); err != nil {
		logx.Error("订单对商家评论添加成功")
	}
	return &good.MerchantContentResponse{
		Id: int64(contents.ID),
	}, nil
}
